##
#   Project: gmediacatalog - Catalog your media to find them later
#    Author: Fabio Castelli <muflone@vbsimple.net>
# Copyright: 2010 Fabio Castelli
#   License: GPL-2+
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 2 of the License, or (at your option)
#  any later version.
# 
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
# 
# On Debian GNU/Linux systems, the full text of the GNU General Public License
# can be found in the file /usr/share/common-licenses/GPL-2.
##

import gtk
import time

def gtk_process_events():
  "Process GTK events"
  while gtk.events_pending():
    gtk.main_iteration()
  return

def get_iter_root(treestore, iter):
  root = iter
  parent = iter
  while parent:
    parent = treestore.iter_parent(parent)
    if parent:
      root = parent
  return root

def get_sensitive(widget):
  "Wrapper to sensitive property"
  return widget.get_property('sensitive')
  
def set_visible(widget, visibility):
  "Wrapper to visible property"
  return widget.set_property('visible', visibility)

def readTextFile(filename):
  "Read a text file and return its content"
  try:
    f = open(filename, 'r')
    text = f.read()
    f.close()
  except:
    text = ''
  return text

# TODO: Replace with gettext.gettext
_ = str

__all__ = [
  'gtk_process_events',
  'get_sensitive',
  'set_visible',
  'readTextFile',
  'get_iter_root',
  '_'
]
